<?php
/**
 * 定时任务控制基类(此类的子类的方法会被定时器免登陆定时请求)
 * 后期可考虑加入请求来源验证，避免非法请求
 */
class Controller_CronJob {
	protected $_error;
	public function __construct() {
		set_time_limit(0);
		$this->db = Model_Db::getInstance();
		$this->writeDb = Model_Db::getInstance('write_db');
		$this->log = new Log();
	}

	/**
	 * 设置错误
	 * @param  string $errorMsg  错误信息
	 * @param  [type] $errorCode 错误代码
	 * @return false
	 * @example return this->_error('错误信息','paramInvalid')
	 */
	protected function _error($errorMsg, $errorCode = "") {
		$this->_error = array("errorMsg" => $errorMsg, 'code' => $errorCode);
		return false;
	}

	/**
	 * 获取错误信息
	 * @return string
	 */
	public function getErrorMsg() {
		if (isset($this->_error) && isset($this->_error['errorMsg'])) {
			return $this->_error['errorMsg'];
		}
		return '';
	}
}